#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>

#include "gsmMsgHandle.h"
#include "modules.h"

#if 0
extern RESULT MSGPROC_init(void);
extern RESULT DATAPROC_init(void);
#endif


int main()
{
    printf("This is gsm application\n");

    //1. sys init 
    //
    if(RC_OK != SYS_init())
    {
        printf("sys init failed\n");
        return RC_FAIL;
    }

	if(SYSM_init() != RC_OK)
		return RC_FAIL;
#if 1    
	if(MSGPROC_init() != RC_OK)
		return RC_FAIL;

	if(DATAPROC_init() != RC_OK)
		return RC_FAIL;
	if(DATASTOR_init() != RC_OK)
		return RC_FAIL;    
#endif	    

    //2. gsm module initialization
    if( !gsmModuleInit() )
    {	
    	printf("gsm module initialization failed. \n");
    	return RC_FAIL; 
    }
    
    //3. create udp msg handler thread 
    if( !initGsmUdpMsgTask() )
    {
        printf("can't create gsmUdptask thread. \n");
    	return RC_FAIL;
    }
    
    //4. start to handle tlv message 
    gsm_tlv_msg_handler();
    
    return 0;
}


